/**
 * Created by Administrator on 2017/3/13 0013.
 */




Page1={
    Create:function() {
        var page = {};
        var whole = new PIXI.DisplayObjectContainer();

        var whiteBG=new PIXI.Graphics();
        whiteBG.beginFill(0xffffff,1);
        whiteBG.drawRect(0,0,740,1136);

        var head1=PSP("page3_1");
        var head2=PSP("page3_2");
        var head3=PSP("page3_3");
        var head4=PSP("page3_4");

        var arr_gold=[];
        var arr_blur=[];

        for(var z=1;z<=6;z++){
            var hanzi=PSP("pic"+z);
            arr_gold.push(hanzi);
            hanzi.anchor.set(0.5);

            var blur=new PIXI.filters.BlurFilter();
            blur.blur=0;
            arr_blur.push(blur);
        }

        whole.addChild(whiteBG);
        // for(var z=0;z<arr_gold.length;z++){
        //     whole.addChild(arr_gold[z]);
        //     arr_gold[z].alpha=0;
        //     switch (Math.round(Math.random()*3)){
        //         case 0: arr_gold[z].x=0;arr_gold[z].y=0;break;
        //         case 1: arr_gold[z].x=0;arr_gold[z].y=1136;break;
        //         case 2: arr_gold[z].x=740;arr_gold[z].y=0;break;
        //         case 3: arr_gold[z].x=740;arr_gold[z].y=1136;break;
        //     }
        // }
        for(var z=0;z<arr_gold.length;z++) {
            whole.addChild(arr_gold[z]);
            arr_gold[z].alpha=0;
            var xx,yy,sc;
            var xv,yv;
            switch(z){
                case 0:xx=8;yy=62;sc=0.8;xv=10;yv=-20;break;
                case 1:xx=306;yy=125;sc=0.8;xv=0;yv=4;break;
                case 2:xx=458;yy=-102;sc=1.2;xv=10;yv=10;break;
                case 3:xx=115;yy=467;sc=0.9;xv=-30;yv=30;break;
                case 4:xx=-27;yy=731;sc=1.2;xv=-40;yv=30;break;
                case 5:xx=487;yy=680;sc=0.8;xv=10;yv=10;break;
            }
            arr_gold[z].x=xx+arr_gold[z].width/2;arr_gold[z].y=yy+arr_gold[z].height/2;
            var aa=Math.random()*2;
            TweenMax.to(arr_gold[z].scale,2+aa,{delay:0.5*z,x:sc,y:sc,yoyo:true,repeat:-1,ease:Cubic.easeInOut});
            TweenMax.to(arr_gold[z],2+aa,{delay:0.5*z,x:arr_gold[z].x+xv,y:arr_gold[z].y+yv,yoyo:true,repeat:-1,ease:Cubic.easeInOut});

        }
        whole.addChild(head1);
        whole.addChild(head2);
        whole.addChild(head3);
        whole.addChild(head4);

        head1.anchor.set(0.5);
        head2.anchor.set(0.5);
        head1.x=305+head1.width/2;head1.y=302+head1.height/2;
        head2.x=308+head2.width/2;head2.y=653+head2.height/2;
        head3.x=183;head3.y=529;

        head4.anchor.set(0.5);
        head4.x=293+head4.width/2;head4.y=71+head4.height/2;

        head1.scale.set(0);
        head2.scale.set(0);
        head4.scale.set(2);
        head1.alpha=0;
        head2.alpha=0;
        head3.alpha=0;
        head4.alpha=0;



        head3.x=183-30;




        page.start=function(){
            TweenMax.to(head1.scale,0.7,{delay:0.5,x:1,y:1,ease:Cubic.easeOut});
            TweenMax.to(head1,0.7,{delay:0.5,alpha:1,ease:Cubic.easeOut});
            TweenMax.to(head2.scale,0.7,{delay:0.8,x:1,y:1,ease:Cubic.easeOut});
            TweenMax.to(head2,0.7,{delay:0.8,alpha:1,ease:Cubic.easeOut});

            TweenMax.to(head4.scale,0.7,{delay:1.2,x:1,y:1,ease:Cubic.easeOut});
            TweenMax.to(head4,0.7,{delay:1.2,alpha:1,ease:Cubic.easeOut});

            TweenMax.to(head3,0.7,{delay:1,alpha:1,x:183,ease:Cubic.easeOut});


            // TweenMax.to(head1.scale,1,{delay:1.5,yoyo:true,repeat:-1,x:0.7,y:0.7});
            // TweenMax.to(head2.scale,1,{delay:1.5,yoyo:true,repeat:-1,x:0.7,y:0.7});

            for(var z=0;z<arr_gold.length;z++){
                TweenMax.to(arr_gold[z],0.7,{delay:1.6+z*0.2,alpha:1,ease:Cubic.easeOut});
            }

        }

        page.start();


        var bl=false;
        setTimeout(function(){
            bl=true;
        },2000)


        page.DoIt=function(){
            // if(bl){
            // for(var z=0;z<arr_gold.length;z++){
            //
            //     if(arr_gold[z].scale.x==1){
            //         arr_gold[z].scale.set(0.99);
            //         var randomTime=Math.random();
            //         TweenMax.to(arr_gold[z],1.7,{delay:0.33*z,alpha:1,x:740/2+randomTime*100-50,y:1136/2-randomTime*100-50});
            //         TweenMax.to(arr_gold[z].scale,2,{delay:0.33*z,x:0,y:0,ease:Cubic.easeInOut});
            //    //guagua     // TweenMax.to(arr_blur[z],1+randomTime,{blur:0,alpha:0,ease:Cubic.easeInOut});
            //     }
            //     else if(arr_gold[z].scale.x==0){
            //         arr_gold[z].scale.x=1;arr_gold[z].scale.y=1;
            //         //guagua   // arr_blur[z].blur=5;
            //         var a=Math.random()*200+200;
            //         switch (Math.round(Math.random()*3)){
            //             case 0: arr_gold[z].x=0-a;arr_gold[z].y=0;break;
            //             case 1: arr_gold[z].x=0-a;arr_gold[z].y=1136;break;
            //             case 2: arr_gold[z].x=740+a;arr_gold[z].y=0;break;
            //             case 3: arr_gold[z].x=740+a;arr_gold[z].y=1136;break;
            //         }
            //
            //     }
            // }
            // }
        }
        page.In=function(){
            TweenMax.to(whole,0.5,{delay:0.5,alpha:1,ease:Cubic.easeOut});
            for(var z=0;z<arr_gold.length;z++){
                TweenMax.to(arr_gold[z],1,{delay:1.4+z*0.2,alpha:1,ease:Cubic.easeOut});
            }
        }
        page.Out=function(){
            TweenMax.to(whole,0.5,{delay:0.5,alpha:0,ease:Cubic.easeOut});
            for(var z=0;z<arr_gold.length;z++){
                TweenMax.to(arr_gold[z],1,{alpha:0,ease:Cubic.easeOut});
            }
        }

        page.ReturnWhole=function(){
            return whole;
        };

        return page;
    }
}
